<?php

/**
 * Class Involved_ShopCartModel
 */

class Involved_ShopCartModel extends BaseModel{

    protected $table = 'shop_cart';


    /**
     * 购物车列表
     * @return mixed
     */
    public function YptShopCart($user_id)
    {

        return DB::table($this->table)
            ->select('shop_cart.product_id','shop_cart.created','number','cart_id','product_name','specificate.price','stock','img1','spec_name','brand_name','a_price')
            ->join('shop_product','shop_product.product_id','=','shop_cart.product_id')
            ->join('shop_brand','shop_brand.brand_id','=','shop_cart.brand_id')
            ->join('specificate','specificate.s_id','=','shop_cart.spec_id')
            ->where('shop_cart.user_id',1)
            ->orderby('shop_cart.created','desc')
            ->get();

    }

    /**
     * 购物车数量
     * @param $user_id
     * @return mixed
     */
    public function YptShopCartCount($user_id)
    {
        return DB::table($this->table)
            ->where('user_id',1)
            ->count();
    }

    /**
     * 购物车查询
     * @param $product_id
     * @param $s_id
     * @param $brand_id
     * @param $user_id
     * @return mixed
     */
    public function CartSel($product_id,$s_id,$brand_id,$user_id)
    {
        return DB::table($this->table)
            ->where('user_id',1)
            ->where('product_id',$product_id)
            ->where('spec_id',$s_id)
            ->where('brand_id',$brand_id)
            ->first();
    }



}